﻿using System;
using System.IO;
using System.Reflection;

namespace EvoGame.Core.Components
{
	public static class EvoApp
	{
		public static string Name
		{
			get { return Assembly.GetEntryAssembly ().GetName ().Name; }
		}

		public static string Path
		{
			get
			{
				var dir =
					String.Format ("{0}{2}EvoGame{2}{1}", Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), EvoApp.Name, System.IO.Path.DirectorySeparatorChar);
				if (Directory.Exists (dir))
				{
					return dir;
				}
				else
				{
					return Directory.CreateDirectory (dir).ToString ();
				}
			}
		}

		public static Version Version
		{
			get
			{
				Version ver;
#if !MONO
				if (ApplicationDeployment.IsNetworkDeployed)
				{
					ver = ApplicationDeployment.CurrentDeployment.CurrentVersion;
				}
				else
				{
#endif
				ver = Assembly.GetEntryAssembly ().GetName ().Version;
#if !MONO
				}
#endif
				return ver;
			}
		}

		public static string LongVersion
		{
			get { return Version.ToString (); }
		}

		public static string Major
		{
			get { return Assembly.GetEntryAssembly ().GetName ().Version.Major.ToString (); }
		}

		public static string Minor
		{
			get { return Assembly.GetEntryAssembly ().GetName ().Version.Minor.ToString (); }
		}

		public static string Revision
		{
			get { return Assembly.GetEntryAssembly ().GetName ().Version.Revision.ToString (); }
		}

		public static string Build
		{
			get { return Assembly.GetEntryAssembly ().GetName ().Version.Build.ToString (); }
		}

		public static string ShortVersion
		{
			get { return String.Format ("{0}.{1}", Major, Minor); }
		}

		public static string FormattedVersion
		{
			get { return String.Format ("{0}, Version {1} | Current User: {2}", Name, ShortVersion, _user); }
		}

		public static string DebugVersion
		{
			get { return String.Format ("{0}, Version {1} | Debug Version licenced to: {2}", Name, LongVersion, _user); }
		}

		public static DebugConsole Debug;

		public static void SetUser(string u)
		{
			_user = u;
		}

		private static string _user = "Anon. Y. Mouse";
	}
}